package views;

import java.awt.Color;
import java.awt.Font;

import javax.swing.JFrame;
import javax.swing.JLabel;

import models.*;
import models.Character;

public class PlayerFrame extends JFrame {

	private int width;
	private int height;
	private Player player;
	
	private JLabel STR_description = new JLabel("Strength:");
	private JLabel STR_value;
	private JLabel AGI_description = new JLabel("Agility:");
	private JLabel AGI_value; 
	private JLabel VIT_description = new JLabel("Vitality:");
	private JLabel VIT_value;
	private JLabel INT_description = new JLabel("Intelligence:");
	private JLabel INT_value;
	private JLabel DEX_description = new JLabel("Dexterity:");
	private JLabel DEX_value;
	
	public PlayerFrame(int width, int height, Player player) {
		this.width = width;
		this.height = height;
		this.player = player;
		this.setLayout(null);
		this.setSize(this.width,this.height);
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		this.setTitle(player.getName());
		this.setResizable(false);
		this.getContentPane().setBackground(Color.white);
		Font textFont = new Font("Verdana", Font.PLAIN, 11);
		
		this.STR_value = new JLabel(Integer.toString(player.getSTR()));
		this.STR_description.setBounds(5, 5, 80, 15);
		this.STR_description.setFont(textFont);
		this.STR_value.setBounds(100, 5, 30, 15);
		this.STR_value.setFont(textFont);
		this.getContentPane().add(this.STR_description);
		this.getContentPane().add(this.STR_value);
		
		this.AGI_value = new JLabel(Integer.toString(player.getAGI()));
		this.AGI_description.setBounds(5, 20, 80, 15);
		this.AGI_description.setFont(textFont);
		this.AGI_value.setBounds(100, 20, 30, 15);
		this.AGI_value.setFont(textFont);
		this.getContentPane().add(this.AGI_description);
		this.getContentPane().add(this.AGI_value);
		
		this.VIT_value = new JLabel(Integer.toString(player.getVIT()));
		this.VIT_description.setBounds(5, 35, 80, 15);
		this.VIT_description.setFont(textFont);
		this.VIT_value.setBounds(100, 35, 30, 15);
		this.VIT_value.setFont(textFont);
		this.getContentPane().add(this.VIT_description);
		this.getContentPane().add(this.VIT_value);
		
		this.INT_value = new JLabel(Integer.toString(player.getINT()));
		this.INT_description.setBounds(5, 50, 80, 15);
		this.INT_description.setFont(textFont);
		this.INT_value.setBounds(100, 50, 30, 15);
		this.INT_value.setFont(textFont);
		this.getContentPane().add(this.INT_description);
		this.getContentPane().add(this.INT_value);
		
		this.DEX_value = new JLabel(Integer.toString(player.getDEX()));
		this.DEX_description.setBounds(5, 65, 80, 15);
		this.DEX_description.setFont(textFont);
		this.DEX_value.setBounds(100, 65, 30, 15);
		this.DEX_value.setFont(textFont);
		this.getContentPane().add(this.DEX_description);
		this.getContentPane().add(this.DEX_value);
		
		this.setVisible(true);
		update();
	}
	
	public void update() {
		this.STR_value.setText(Integer.toString(player.getSTR()));
		this.AGI_value.setText(Integer.toString(player.getAGI()));
		this.VIT_value.setText(Integer.toString(player.getVIT()));
		this.INT_value.setText(Integer.toString(player.getINT()));
		this.DEX_value.setText(Integer.toString(player.getDEX()));
		repaint();
	}
	
}
